package com.team.sns.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
public class StatusReply implements Serializable {

	private static final long serialVersionUID = -3094059458522747863L;

	private String id;
	private String content;
	private String statusId;
	private String replyUserId;
	private Date replyDate;
	private StatusReply parent;
	private Set<StatusReply> children = new HashSet<StatusReply>();

	@Id @Column(nullable=false,length=36)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(length = 1000, nullable = false)
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(length = 20, nullable = false)
	public String getStatusId() {
		return statusId;
	}

	public void setStatusId(String statusId) {
		this.statusId = statusId;
	}

	@Column(length = 20, nullable = false)
	public String getReplyUserId() {
		return replyUserId;
	}

	public void setReplyUserId(String replyUserId) {
		this.replyUserId = replyUserId;
	}

	@Column(length = 22, nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getReplyDate() {
		return replyDate;
	}

	public void setReplyDate(Date replyDate) {
		this.replyDate = replyDate;
	}
	@JoinColumn(name = "parent_id")
	@ManyToOne(cascade = {CascadeType.REFRESH})
	public StatusReply getParent() {
		return parent;
	}

	public void setParent(StatusReply parent) {
		this.parent = parent;
	}

	@OneToMany(mappedBy = "children",cascade={CascadeType.REFRESH})
	public Set<StatusReply> getChildren() {
		return children;
	}

	public void setChildren(Set<StatusReply> children) {
		this.children = children;
	}

}
